﻿using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using MyFloridaHouse.DataAccess.Extensions;
using MyFloridaHouse.LibDTO;

namespace MyFloridaHouse.DataAccess
{
    public partial class DAL_CensusData
    {
        // This Method supports the print functions in libPrint

        /// <summary>
        /// Gets the census geometry from the database.
        /// Returns a collection of pointers (ID  fields) to layer data as a list of: <see cref="CensusGeometryDTO"/>.
        /// </summary>
        /// <returns>List of <see cref="CensusGeometryDTO"/></returns>
        /// <remarks>SPROC: usp_GetCensusGeometry</remarks>
        public List<ShapeDTO> GetCountyShapes()
        {
            List<ShapeDTO> itemList = new List<ShapeDTO>();

            //string storedProcedureName = "usp_GetCensusGeometry";
            string storedProcedureName = "usp_tl10GetCountyShapes10";

            using (SqlConnection db = Connect())
            {
                SqlCommand StoredProcedureCommand = new SqlCommand(storedProcedureName, db);
                StoredProcedureCommand.CommandType = CommandType.StoredProcedure;
                StoredProcedureCommand.CommandTimeout = 60000;

                db.Open();
                using (SqlDataReader rdr = StoredProcedureCommand.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        itemList.Add(ShapeDTODataContract.DataContract(rdr));
                    }
                }
            }

            return itemList;
        }

    }
}
